/**
 * print.h
 *
 *  Created on: 2021.05.22
 *      Author: wangbing
 *      Email : mz8023yt@163.com
 */

#ifndef _MAZ_ASSERTS_H_
#define _MAZ_ASSERTS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "maz/print.h"

#define ASSERT_RETVAL(condition, ret, fmt, msg...)                      \
    if (condition)                                                      \
    {                                                                   \
        dlog(DERR, fmt, ##msg);                                         \
        return ret;                                                     \
    }

#define ASSERT_RET(condition, fmt, msg...)                              \
    if (condition)                                                      \
    {                                                                   \
        dlog(DERR, fmt, ##msg);                                         \
        return;                                                         \
    }

#define ASSERT_CTN(condition, fmt, msg...)                              \
    if (condition)                                                      \
    {                                                                   \
        dlog(DERR, fmt, ##msg);                                         \
        continue;                                                       \
    }

#define ASSERT_BRK(condition, fmt, msg...)                              \
    if (condition)                                                      \
    {                                                                   \
        dlog(DERR, fmt, ##msg);                                         \
        break;                                                          \
    }

#define ASSERT_RETVAL_NOMSG(condition, ret)                             \
    if (condition)                                                      \
    {                                                                   \
        return ret;                                                     \
    }

#define ASSERT_RET_NOMSG(condition)                                     \
    if (condition)                                                      \
    {                                                                   \
        return;                                                         \
    }

#define ASSERT_CTN_NOMSG(condition)                                     \
    if (condition)                                                      \
    {                                                                   \
        continue;                                                       \
    }

#define ASSERT_BRK_NOMSG(condition)                                     \
    if (condition)                                                      \
    {                                                                   \
        break;                                                          \
    }

#ifdef __cplusplus
}
#endif

#endif /* _MAZ_ASSERTS_H_ */

